import fs from 'node:fs'
import path from 'node:path'

export default defineEventHandler(async (event): Promise<ReqPayLoad<string[]>> => {
  const assets = path.join(process.cwd(), "public", "upload")
  const fileDir = fs.readdirSync(assets, { recursive: true }).filter((file): file is string => {
    if (typeof file !== 'string')
      return false

    // 不是二级目录
    if (!file.includes('\\') || file.split('\\')[0] !== 'video')
      return false

    // 不支持播放avi
    if (file.endsWith('.avi'))
      return false
    return true
  })
  // const videoSrc = 
  return wrapToPayLoad(fileDir)
})
